<?php
    $attributes = array(
        'style'         => 'color: red',
        'font-weight'   =>  'bold'
    );
    //chon ngan hang
    echo form_label($this->lang->line('choicebank'), 'choicebank',$attributes);
    echo form_dropdown('choicebank', $this->booking_model->getListBank(), 0,'id="choicebank"');
    echo form_error('choicebank');
    // thong tin ngan hang
    echo form_label($this->lang->line('bank_info'), 'bank_info',$attributes);
    echo form_textarea(array('name' => 'bank_info', 'id' => 'bank_info', 'value' => '','rows'=>'5'));
    echo form_error('bank_info');  
?>

<script>
$(document).ready(function() {
    $("#choicebank").change(function() {
        var x = $(this).val();
        if(x == 0){
            document.getElementById("bank_info").value = "";
            alert('Vui lòng chọn!');
        } else {
            updateURL = '/auth/booking/getInfoBank?id='+x;
            $.ajax(
            {
                    url : updateURL,
                    success:function(data)
                    {
                       var data = JSON.parse(data);
                       document.getElementById("bank_info").value = data['bank_name']+'\nTài khoản:'+data['account_name']+'\nSố tài khoản:'+data['account_number']+'\nChi nhánh:'+data['aff'];
                    },
                    error: function() 
                    {
                        
                    }
            });
        }
    });
});
</script>